package view;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ExamRules extends JFrame implements ActionListener{
    JTextArea area;
    JButton btn;
    JPanel panel;
    public ExamRules(String s){
        super("考试准则");
        ImageIcon icon = new ImageIcon("src\\main\\resources\\img\\rules.png");
        this.setIconImage(icon.getImage());
        area = new JTextArea();
        area.setLineWrap(true);     // 自动换行
        area.setText(s);
        area.setEditable(false);
        btn = new JButton("确认");
        panel = new JPanel();
        panel.setLayout(new FlowLayout());
        panel.add(btn);
        btn.addActionListener(this);
        this.setLayout(new BorderLayout());
        this.add(area,BorderLayout.CENTER);
        this.add(panel,BorderLayout.SOUTH);
        this.setVisible(true);
        this.setBounds(500,250,400,300);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == btn){
            this.dispose();
        }
    }
}
